using System;
using System.Drawing;
using System.Collections;
using System.ComponentModel;
using System.Windows.Forms;
using MobileClient.UIProcessService;

namespace MobileClient
{
	/// <summary>
	/// Summary description for frmEntry.
	/// </summary>
	public class frmEntry : System.Windows.Forms.Form
	{
		private MobileClient.ImageButton btnPrev;
		private MobileClient.ImageButton btnNext;
		private MobileClient.ImageButton btnHome;
		private System.Windows.Forms.MainMenu mnuMain;
		private Microsoft.WindowsCE.Forms.InputPanel pnlSIP;
		private System.Windows.Forms.Panel pnlEntry;
		private System.Windows.Forms.TextBox txtPrompt;
		private FormResourceDirection m_objDirection;
        private MobileClient.UIProcessService.FormResource m_objResource;
		private Point m_nOriginalLocation;
		private Point m_nNewLocation;

        private ctlAddressEntry objAddressEntry;
        private ctlAddressEntryNA objAddressEntryNA;
        private ctlDateEntry objDateEntry;
        private ctlDateEntryNA objDateEntryNA;
        private ctlDateTimeEntry objDateTimeEntry;
        private ctlDateTimeEntryNA objDateTimeEntryNA;
        private ctlGraphicAnnotation objGraphicAnnotation;
        private ctlGraphicDisplay objGraphicDisplay;
        private ctlMultiSelectEntry objMultiSelectEntry;
        private ctlMultiSelectOtherEntry objMultiSelectOtherEntry;
        private ctlNameEntry objNameEntry;
        private ctlNoteEntry objNoteEntry;
        private ctlNumberEntry objNumberEntry;
        private ctlNumberEntryNA objNumberEntryNA;
        private ctlPasswordEntry objPasswordEntry;
        private ctlPhoneEntry objPhoneEntry;
        private ctlPhoneEntryNA objPhoneEntryNA;
        private ctlPostalCodeEntry objPostalCodeEntry;
        private ctlPostalCodeEntryNA objPostalCodeEntryNA;
        private ctlSignatureCapture objSignatureCapture;
        private ctlSingleSelectEntry objSingleSelectEntry;
        private ctlSingleSelectOtherEntry objSingleSelectOtherEntry;
        private ctlYesNoEntry objYesNoEntry;
        private ctlTextEntry objTextEntry;

	
		public frmEntry()
		{
			//
			// Required for Windows Form Designer support
			//
			InitializeComponent();

			m_objDirection = new FormResourceDirection();
			m_objDirection.Direction = FormResourceDirection.FormResourceDirectionType.Next;
			m_nOriginalLocation = new System.Drawing.Point(4, 84);
			m_nNewLocation = new System.Drawing.Point(m_nOriginalLocation.X, (m_nOriginalLocation.Y - 80));
			// create the image buttons
			this.btnPrev = new MobileClient.ImageButton();
			this.btnNext = new MobileClient.ImageButton();
			this.btnHome = new MobileClient.ImageButton();
			// 
			// btnPrev
			// 
			this.btnPrev.Location = new System.Drawing.Point(4, 245);
			this.btnPrev.Size = new Size(72, 20);
			this.btnPrev.ImageButtonUp = new Bitmap(System.Reflection.Assembly.GetExecutingAssembly().GetManifestResourceStream("MobileClient.Graphics.previous_up.gif"));
			this.btnPrev.ImageButtonDown = new Bitmap(System.Reflection.Assembly.GetExecutingAssembly().GetManifestResourceStream("MobileClient.Graphics.previous_down.gif"));
            this.btnPrev.Text = MobileClient.Properties.Resources.lblPrev;
			this.btnPrev.Visible = true;
			this.btnPrev.Type = MobileClient.ImageButton.ButtonType.Button;
			this.btnPrev.Click += new System.EventHandler(this.btnPrev_Click);
			// 
			// btnNext
			// 
			this.btnNext.Location = new System.Drawing.Point(164, 245);
			this.btnNext.Size = new Size(72, 20);
			this.btnNext.ImageButtonUp = new Bitmap(System.Reflection.Assembly.GetExecutingAssembly().GetManifestResourceStream("MobileClient.Graphics.next_up.gif"));
			this.btnNext.ImageButtonDown = new Bitmap(System.Reflection.Assembly.GetExecutingAssembly().GetManifestResourceStream("MobileClient.Graphics.next_down.gif"));
            this.btnNext.Text = MobileClient.Properties.Resources.lblNext;
			this.btnNext.Visible = true;
			this.btnNext.Type = MobileClient.ImageButton.ButtonType.Button;
			this.btnNext.Click += new System.EventHandler(this.btnNext_Click);
			// 
			// btnHome
			// 
			this.btnHome.Location = new System.Drawing.Point(84, 245);
			this.btnHome.Size = new Size(72, 20);
			this.btnHome.ImageButtonUp = new Bitmap(System.Reflection.Assembly.GetExecutingAssembly().GetManifestResourceStream("MobileClient.Graphics.home_up.gif"));
			this.btnHome.ImageButtonDown = new Bitmap(System.Reflection.Assembly.GetExecutingAssembly().GetManifestResourceStream("MobileClient.Graphics.home_down.gif"));
            this.btnHome.Text = MobileClient.Properties.Resources.lblHome;
			this.btnHome.Visible = true;
			this.btnHome.Type = MobileClient.ImageButton.ButtonType.Button;
			this.btnHome.Click += new System.EventHandler(this.btnHome_Click);
			// add the buttons to the form
			this.Controls.Add(this.btnHome);
			this.Controls.Add(this.btnNext);
			this.Controls.Add(this.btnPrev);
		}

        public MobileClient.UIProcessService.FormResource ResourceInfo
		{
			get { return m_objResource; }
			set { m_objResource = value; }
		}

		public FormResourceDirection Direction
		{
			get { return m_objDirection; }
			set { m_objDirection = value; }
		}

		/// <summary>
		/// Clean up any resources being used.
		/// </summary>
		protected override void Dispose( bool disposing )
		{
			base.Dispose( disposing );
		}

		#region Windows Form Designer generated code
		/// <summary>
		/// Required method for Designer support - do not modify
		/// the contents of this method with the code editor.
		/// </summary>
		private void InitializeComponent()
		{
            this.txtPrompt = new System.Windows.Forms.TextBox();
            this.mnuMain = new System.Windows.Forms.MainMenu();
            this.pnlSIP = new Microsoft.WindowsCE.Forms.InputPanel();
            this.pnlEntry = new System.Windows.Forms.Panel();
            this.SuspendLayout();
            // 
            // txtPrompt
            // 
            this.txtPrompt.BackColor = System.Drawing.SystemColors.Menu;
            this.txtPrompt.Location = new System.Drawing.Point(4, 4);
            this.txtPrompt.Multiline = true;
            this.txtPrompt.Name = "txtPrompt";
            this.txtPrompt.ReadOnly = true;
            this.txtPrompt.Size = new System.Drawing.Size(232, 76);
            this.txtPrompt.TabIndex = 1;
            this.txtPrompt.Text = MobileClient.Properties.Resources.lblPrompt;
            // 
            // pnlSIP
            // 
            this.pnlSIP.EnabledChanged += new System.EventHandler(this.pnlSIP_EnabledChanged);
            // 
            // pnlEntry
            // 
            this.pnlEntry.Location = new System.Drawing.Point(4, 84);
            this.pnlEntry.Name = "pnlEntry";
            this.pnlEntry.Size = new System.Drawing.Size(232, 156);
            // 
            // frmEntry
            // 
            this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Inherit;
            this.ClientSize = new System.Drawing.Size(238, 295);
            this.Controls.Add(this.pnlEntry);
            this.Controls.Add(this.txtPrompt);
            this.Menu = this.mnuMain;
            this.Name = "frmEntry";
            this.Text = MobileClient.Properties.Resources.lblTitle;
            this.Load += new System.EventHandler(this.Form_Load);
            this.ResumeLayout(false);

		}
		#endregion

		private void Form_Load(object sender, System.EventArgs e)
		{
			clsModifyButtons.HideDoneButton(clsModifyButtons.GetHWnd(this));
			clsModifyButtons.HideXButton(clsModifyButtons.GetHWnd(this));
			LoadSettings();
		}

		private void btnPrev_Click(object sender, System.EventArgs e)
		{
			m_objDirection.Direction = FormResourceDirection.FormResourceDirectionType.Previous;
			this.DialogResult = DialogResult.OK;
			SaveSettings();
			this.Close();
		}

		private void btnHome_Click(object sender, System.EventArgs e)
		{
			m_objDirection.Direction = FormResourceDirection.FormResourceDirectionType.Home;
			this.DialogResult = DialogResult.Cancel;
			SaveSettings();
			this.Close();
		}

		private void btnNext_Click(object sender, System.EventArgs e)
		{
			m_objDirection.Direction = FormResourceDirection.FormResourceDirectionType.Next;
			this.DialogResult = DialogResult.OK;
			SaveSettings();
			this.Close();
		}

		private void LoadSettings()
		{
			this.Text = m_objResource.Title;
			this.txtPrompt.Text = m_objResource.Prompt;
			this.pnlEntry.Location = m_nOriginalLocation;
            if(m_objResource is AddressEntry)
            {
				this.txtPrompt.Size = new System.Drawing.Size(232, 76);
				if(this.objAddressEntry == null)
				{
					this.objAddressEntry = new ctlAddressEntry();
					this.objAddressEntry.Location = new System.Drawing.Point(0, 0);
					this.objAddressEntry.Size = new System.Drawing.Size(240, 140);
					this.objAddressEntry.SIPPanel = pnlSIP;
					pnlEntry.Controls.Add(objAddressEntry);
				}
				this.objAddressEntry.Entry = (AddressEntry)m_objResource;
				this.objAddressEntry.LoadSettings();
				this.objAddressEntry.Visible = true;
				this.pnlEntry.Visible = true;
            }
            else if(m_objResource is AddressEntryNA)
            {
				this.txtPrompt.Size = new System.Drawing.Size(232, 76);
				if(this.objAddressEntryNA == null)
				{
					this.objAddressEntryNA = new ctlAddressEntryNA();
					this.objAddressEntryNA.Location = new System.Drawing.Point(0, 0);
					this.objAddressEntryNA.Size = new System.Drawing.Size(240, 140);
					this.objAddressEntryNA.SIPPanel = pnlSIP;
					pnlEntry.Controls.Add(objAddressEntry);
				}
				this.objAddressEntryNA.Entry = (AddressEntryNA)m_objResource;
				this.objAddressEntryNA.LoadSettings();
				this.objAddressEntryNA.Visible = true;
				this.pnlEntry.Visible = true;
			}
			else if(m_objResource is DateEntry)
            {
				this.txtPrompt.Size = new System.Drawing.Size(232, 76);
				if(this.objDateEntry == null)
				{
					this.objDateEntry = new ctlDateEntry();
					this.objDateEntry.Location = new System.Drawing.Point(0, 0);
					this.objDateEntry.Size = new System.Drawing.Size(240, 140);
					pnlEntry.Controls.Add(objDateEntry);
				}
				this.objDateEntry.Entry = (DateEntry)m_objResource;
				this.objDateEntry.LoadSettings();
				this.objDateEntry.Visible = true;
				this.pnlEntry.Visible = true;
			}
			else if(m_objResource is DateEntryNA)
            {
				this.txtPrompt.Size = new System.Drawing.Size(232, 76);
				if(this.objDateEntryNA == null)
				{
					this.objDateEntryNA = new ctlDateEntryNA();
					this.objDateEntryNA.Location = new System.Drawing.Point(0, 0);
					this.objDateEntryNA.Size = new System.Drawing.Size(240, 140);
					pnlEntry.Controls.Add(objDateEntryNA);
				}
				this.objDateEntryNA.Entry = (DateEntryNA)m_objResource;
				this.objDateEntryNA.LoadSettings();
				this.objDateEntryNA.Visible = true;
				this.pnlEntry.Visible = true;
			}
			else if(m_objResource is DateTimeEntry)
            {
				this.txtPrompt.Size = new System.Drawing.Size(232, 76);
				if(this.objDateTimeEntry == null)
				{
					this.objDateTimeEntry = new ctlDateTimeEntry();
					this.objDateTimeEntry.Location = new System.Drawing.Point(0, 0);
					this.objDateTimeEntry.Size = new System.Drawing.Size(240, 140);
					this.objDateTimeEntry.SIPPanel = pnlSIP;
					pnlEntry.Controls.Add(objDateTimeEntry);
				}
				this.objDateTimeEntry.Entry = (DateTimeEntry)m_objResource;
				this.objDateTimeEntry.LoadSettings();
				this.objDateTimeEntry.Visible = true;
				this.pnlEntry.Visible = true;
			}
			else if(m_objResource is DateTimeEntryNA)
            {
				this.txtPrompt.Size = new System.Drawing.Size(232, 76);
				if(this.objDateTimeEntryNA == null)
				{
					this.objDateTimeEntryNA = new ctlDateTimeEntryNA();
					this.objDateTimeEntryNA.Location = new System.Drawing.Point(0, 0);
					this.objDateTimeEntryNA.Size = new System.Drawing.Size(240, 140);
					this.objDateTimeEntryNA.SIPPanel = pnlSIP;
					pnlEntry.Controls.Add(objDateTimeEntryNA);
				}
				this.objDateTimeEntryNA.Entry = (DateTimeEntryNA)m_objResource;
				this.objDateTimeEntryNA.LoadSettings();
				this.objDateTimeEntryNA.Visible = true;
				this.pnlEntry.Visible = true;
			}
			else if(m_objResource is MultiSelectEntry)
            {
				this.txtPrompt.Size = new System.Drawing.Size(232, 76);
				if(this.objMultiSelectEntry == null)
				{
					this.objMultiSelectEntry = new ctlMultiSelectEntry();
					this.objMultiSelectEntry.Location = new System.Drawing.Point(0, 0);
					this.objMultiSelectEntry.Size = new System.Drawing.Size(240, 140);
					pnlEntry.Controls.Add(objMultiSelectEntry);
				}
				this.objMultiSelectEntry.Entry = (MultiSelectEntry)m_objResource;
				this.objMultiSelectEntry.LoadSettings();
				this.objMultiSelectEntry.Visible = true;
				this.pnlEntry.Visible = true;
			}
			else if(m_objResource is MultiSelectOtherEntry)
            {
				this.txtPrompt.Size = new System.Drawing.Size(232, 76);
				if(this.objMultiSelectOtherEntry == null)
				{
					this.objMultiSelectOtherEntry = new ctlMultiSelectOtherEntry();
					this.objMultiSelectOtherEntry.Location = new System.Drawing.Point(0, 0);
					this.objMultiSelectOtherEntry.Size = new System.Drawing.Size(240, 140);
					pnlEntry.Controls.Add(objMultiSelectOtherEntry);
				}
				this.objMultiSelectOtherEntry.Entry = (MultiSelectOtherEntry)m_objResource;
				this.objMultiSelectOtherEntry.LoadSettings();
				this.objMultiSelectOtherEntry.Visible = true;
				this.pnlEntry.Visible = true;
			}
			else if(m_objResource is NameEntry)
            {
				this.txtPrompt.Size = new System.Drawing.Size(232, 76);
				if(this.objNameEntry == null)
				{
					this.objNameEntry = new ctlNameEntry();
					this.objNameEntry.Location = new System.Drawing.Point(0, 0);
					this.objNameEntry.Size = new System.Drawing.Size(240, 140);
					this.objNameEntry.SIPPanel = pnlSIP;
					pnlEntry.Controls.Add(objNameEntry);
				}
				this.objNameEntry.Entry = (NameEntry)m_objResource;
				this.objNameEntry.LoadSettings();
				this.objNameEntry.Visible = true;
				this.pnlEntry.Visible = true;
			}
			else if(m_objResource is NoteEntry)
            {
				this.txtPrompt.Size = new System.Drawing.Size(232, 76);
				if(this.objNoteEntry == null)
				{
					this.objNoteEntry = new ctlNoteEntry();
					this.objNoteEntry.Location = new System.Drawing.Point(0, 0);
					this.objNoteEntry.Size = new System.Drawing.Size(240, 140);
					this.objNoteEntry.SIPPanel = pnlSIP;
					pnlEntry.Controls.Add(objNoteEntry);
				}
				this.objNoteEntry.Entry = (NoteEntry)m_objResource;
				this.objNoteEntry.LoadSettings();
				this.objNoteEntry.Visible = true;
				this.pnlEntry.Visible = true;
			}
			else if(m_objResource is NumberEntry)
            {
				this.txtPrompt.Size = new System.Drawing.Size(232, 76);
				if(this.objNumberEntry == null)
				{
					this.objNumberEntry = new ctlNumberEntry();
					this.objNumberEntry.Location = new System.Drawing.Point(0, 0);
					this.objNumberEntry.Size = new System.Drawing.Size(240, 140);
					pnlEntry.Controls.Add(objNumberEntry);
				}
				this.objNumberEntry.Entry = (NumberEntry)m_objResource;
				this.objNumberEntry.LoadSettings();
				this.objNumberEntry.Visible = true;
				this.pnlEntry.Visible = true;
			}
			else if(m_objResource is NumberEntryNA)
            {
				this.txtPrompt.Size = new System.Drawing.Size(232, 76);
				if(this.objNumberEntryNA == null)
				{
					this.objNumberEntryNA = new ctlNumberEntryNA();
					this.objNumberEntryNA.Location = new System.Drawing.Point(0, 0);
					this.objNumberEntryNA.Size = new System.Drawing.Size(240, 140);
					pnlEntry.Controls.Add(objNumberEntryNA);
				}
				this.objNumberEntryNA.Entry = (NumberEntryNA)m_objResource;
				this.objNumberEntryNA.LoadSettings();
				this.objNumberEntryNA.Visible = true;
				this.pnlEntry.Visible = true;
			}
			else if(m_objResource is PasswordEntry)
            {
				this.txtPrompt.Size = new System.Drawing.Size(232, 76);
				if(this.objPasswordEntry == null)
				{
					this.objPasswordEntry = new ctlPasswordEntry();
					this.objPasswordEntry.Location = new System.Drawing.Point(0, 0);
					this.objPasswordEntry.Size = new System.Drawing.Size(240, 140);
					this.objPasswordEntry.SIPPanel = pnlSIP;
					pnlEntry.Controls.Add(objPasswordEntry);
				}
				this.objPasswordEntry.Entry = (PasswordEntry)m_objResource;
				this.objPasswordEntry.LoadSettings();
				this.objPasswordEntry.Visible = true;
				this.pnlEntry.Visible = true;
			}
			else if(m_objResource is PhoneEntry)
            {
				this.txtPrompt.Size = new System.Drawing.Size(232, 76);
				if(this.objPhoneEntry == null)
				{
					this.objPhoneEntry = new ctlPhoneEntry();
					this.objPhoneEntry.Location = new System.Drawing.Point(0, 0);
					this.objPhoneEntry.Size = new System.Drawing.Size(240, 140);
					this.objPhoneEntry.SIPPanel = pnlSIP;
					pnlEntry.Controls.Add(objPhoneEntry);
				}
				this.objPhoneEntry.Entry = (PhoneEntry)m_objResource;
				this.objPhoneEntry.LoadSettings();
				this.objPhoneEntry.Visible = true;
				this.pnlEntry.Visible = true;
			}
			else if(m_objResource is PhoneEntryNA)
            {
				this.txtPrompt.Size = new System.Drawing.Size(232, 76);
				if(this.objPhoneEntryNA == null)
				{
					this.objPhoneEntryNA = new ctlPhoneEntryNA();
					this.objPhoneEntryNA.Location = new System.Drawing.Point(0, 0);
					this.objPhoneEntryNA.Size = new System.Drawing.Size(240, 140);
					this.objPhoneEntryNA.SIPPanel = pnlSIP;
					pnlEntry.Controls.Add(objPhoneEntryNA);
				}
				this.objPhoneEntryNA.Entry = (PhoneEntryNA)m_objResource;
				this.objPhoneEntryNA.LoadSettings();
				this.objPhoneEntryNA.Visible = true;
				this.pnlEntry.Visible = true;
			}
			else if(m_objResource is PostalCodeEntry)
            {
				this.txtPrompt.Size = new System.Drawing.Size(232, 76);
				if(this.objPostalCodeEntry == null)
				{
					this.objPostalCodeEntry = new ctlPostalCodeEntry();
					this.objPostalCodeEntry.Location = new System.Drawing.Point(0, 0);
					this.objPostalCodeEntry.Size = new System.Drawing.Size(240, 140);
					pnlEntry.Controls.Add(objPostalCodeEntry);
				}
				this.objPostalCodeEntry.Entry = (PostalCodeEntry)m_objResource;
				this.objPostalCodeEntry.LoadSettings();
				this.objPostalCodeEntry.Visible = true;
				this.pnlEntry.Visible = true;
			}
			else if(m_objResource is PostalCodeEntryNA)
            {
				this.txtPrompt.Size = new System.Drawing.Size(232, 76);
				if(this.objPostalCodeEntryNA == null)
				{
					this.objPostalCodeEntryNA = new ctlPostalCodeEntryNA();
					this.objPostalCodeEntryNA.Location = new System.Drawing.Point(0, 0);
					this.objPostalCodeEntryNA.Size = new System.Drawing.Size(240, 140);
					pnlEntry.Controls.Add(objPostalCodeEntryNA);
				}
				this.objPostalCodeEntryNA.Entry = (PostalCodeEntryNA)m_objResource;
				this.objPostalCodeEntryNA.LoadSettings();
				this.objPostalCodeEntryNA.Visible = true;
				this.pnlEntry.Visible = true;
			}
			else if(m_objResource is SignatureCaptureEntry)
            {
				this.txtPrompt.Size = new System.Drawing.Size(232, 76);
				if(this.objSignatureCapture == null)
				{
					this.objSignatureCapture = new ctlSignatureCapture();
					this.objSignatureCapture.Location = new System.Drawing.Point(0, 0);
					this.objSignatureCapture.Size = new System.Drawing.Size(240, 140);
					pnlEntry.Controls.Add(objSignatureCapture);
				}
				this.objSignatureCapture.Entry = (SignatureCaptureEntry)m_objResource;
				this.objSignatureCapture.LoadSettings();
				this.objSignatureCapture.Visible = true;
				this.pnlEntry.Visible = true;
			}
			else if(m_objResource is SingleSelectEntry)
            {
				this.txtPrompt.Size = new System.Drawing.Size(232, 76);
				if(this.objSingleSelectEntry == null)
				{
					this.objSingleSelectEntry = new ctlSingleSelectEntry();
					this.objSingleSelectEntry.Location = new System.Drawing.Point(0, 0);
					this.objSingleSelectEntry.Size = new System.Drawing.Size(240, 140);
					pnlEntry.Controls.Add(objSingleSelectEntry);
				}
				this.objSingleSelectEntry.Entry = (SingleSelectEntry)m_objResource;
				this.objSingleSelectEntry.LoadSettings();
				this.objSingleSelectEntry.Visible = true;
				this.pnlEntry.Visible = true;
			}
			else if(m_objResource is SingleSelectOtherEntry)
            {
				this.txtPrompt.Size = new System.Drawing.Size(232, 76);
				if(this.objSingleSelectOtherEntry == null)
				{
					this.objSingleSelectOtherEntry = new ctlSingleSelectOtherEntry();
					this.objSingleSelectOtherEntry.Location = new System.Drawing.Point(0, 0);
					this.objSingleSelectOtherEntry.Size = new System.Drawing.Size(240, 140);
					pnlEntry.Controls.Add(objSingleSelectOtherEntry);
				}
				this.objSingleSelectOtherEntry.Entry = (SingleSelectOtherEntry)m_objResource;
				this.objSingleSelectOtherEntry.LoadSettings();
				this.objSingleSelectOtherEntry.Visible = true;
				this.pnlEntry.Visible = true;
			}
			else if(m_objResource is TextEntry)
            {
				this.txtPrompt.Size = new System.Drawing.Size(232, 76);
				if(this.objTextEntry == null)
				{
					this.objTextEntry = new ctlTextEntry();
					this.objTextEntry.Location = new System.Drawing.Point(0, 0);
					this.objTextEntry.Size = new System.Drawing.Size(240, 140);
					this.objTextEntry.SIPPanel = pnlSIP;
					pnlEntry.Controls.Add(objTextEntry);
				}
				this.objTextEntry.Entry = (TextEntry)m_objResource;
				this.objTextEntry.LoadSettings();
				this.objTextEntry.Visible = true;
				this.pnlEntry.Visible = true;
			}
			else if(m_objResource is YesNoEntry)
            {
				this.txtPrompt.Size = new System.Drawing.Size(232, 76);
				if(this.objYesNoEntry == null)
				{
					this.objYesNoEntry = new ctlYesNoEntry();
					this.objYesNoEntry.Location = new System.Drawing.Point(0, 0);
					this.objYesNoEntry.Size = new System.Drawing.Size(240, 140);
					pnlEntry.Controls.Add(objYesNoEntry);
				}
				this.objYesNoEntry.Entry = (YesNoEntry)m_objResource;
				this.objYesNoEntry.LoadSettings();
				this.objYesNoEntry.Visible = true;
				this.pnlEntry.Visible = true;
			}
			else if(m_objResource is GraphicDisplay)
            {
				if(this.objGraphicDisplay == null)
				{
					this.objGraphicDisplay = new ctlGraphicDisplay();
					this.objGraphicDisplay.Location = new System.Drawing.Point(0, 0);
					this.objGraphicDisplay.Size = new System.Drawing.Size(240, 140);
					pnlEntry.Controls.Add(objGraphicDisplay);
				}
				this.objGraphicDisplay.ImagePath = SettingValues.GetImagePath();
				this.objGraphicDisplay.Entry = (GraphicDisplay)m_objResource;
				if(this.objGraphicDisplay.Entry.FullScreen)
				{
					this.txtPrompt.Visible = false;
					pnlEntry.Location = new System.Drawing.Point(4, 4);
					pnlEntry.Size = new System.Drawing.Size(232, 232);
					this.objGraphicDisplay.Location = new System.Drawing.Point(0, 0);
					this.objGraphicDisplay.Size = new System.Drawing.Size(240, 229);
				}
				else
				{
					this.txtPrompt.Visible = true;
					this.txtPrompt.Size = new System.Drawing.Size(232, 76);
					this.pnlEntry.Location = new System.Drawing.Point(4, 84);
					this.pnlEntry.Size = new System.Drawing.Size(232, 156);
					this.objGraphicDisplay.Location = new System.Drawing.Point(0, 0);
					this.objGraphicDisplay.Size = new System.Drawing.Size(240, 140);
				}
				this.objGraphicDisplay.LoadSettings();
				this.objGraphicDisplay.Visible = true;
				this.pnlEntry.Visible = true;
			}
            else if (m_objResource is GraphicAnnotation)
            {
                this.txtPrompt.Size = new System.Drawing.Size(232, 76);
                if (this.objGraphicAnnotation == null)
                {
                    this.objGraphicAnnotation = new ctlGraphicAnnotation();
                    this.objGraphicAnnotation.Location = new System.Drawing.Point(0, 0);
                    this.objGraphicAnnotation.Size = new System.Drawing.Size(240, 140);
                    pnlEntry.Controls.Add(objGraphicAnnotation);
                }
                this.objGraphicAnnotation.ImagePath = SettingValues.GetImagePath();
                this.objGraphicAnnotation.Entry = (GraphicAnnotation)m_objResource;
                if (this.objGraphicAnnotation.Entry.FullScreen)
                {
                    this.txtPrompt.Visible = false;
                    pnlEntry.Location = new System.Drawing.Point(4, 4);
                    pnlEntry.Size = new System.Drawing.Size(232, 232);
                    this.objGraphicAnnotation.Location = new System.Drawing.Point(0, 0);
                    this.objGraphicAnnotation.Size = new System.Drawing.Size(240, 229);
                }
                else
                {
                    this.txtPrompt.Visible = true;
                    this.txtPrompt.Size = new System.Drawing.Size(232, 76);
                    this.pnlEntry.Location = new System.Drawing.Point(4, 84);
                    this.pnlEntry.Size = new System.Drawing.Size(232, 156);
                    this.objGraphicAnnotation.Location = new System.Drawing.Point(0, 0);
                    this.objGraphicAnnotation.Size = new System.Drawing.Size(240, 140);
                }
                this.objGraphicAnnotation.LoadSettings();
                this.objGraphicAnnotation.Visible = true;
                this.pnlEntry.Visible = true;
            }
            else
            {
                this.pnlEntry.Visible = false;
                this.txtPrompt.Size = new System.Drawing.Size(232, 232);
            }

			if(m_objResource is TextPrompt)
			{
				if(this.txtPrompt.TextLength > 300)
				{
					this.txtPrompt.ScrollBars = ScrollBars.Vertical;
				}
				else
				{
					this.txtPrompt.ScrollBars = ScrollBars.None;
				}
			}
			else
			{
				if(this.txtPrompt.TextLength > 150)
				{
					this.txtPrompt.ScrollBars = ScrollBars.Vertical;
				}
				else
				{
					this.txtPrompt.ScrollBars = ScrollBars.None;
				}
			}
		}

		private void SaveSettings()
		{
			if (m_objResource is AddressEntry)
            {
				if(this.objAddressEntry != null)
				{
					this.objAddressEntry.SaveSettings();
					m_objResource = this.objAddressEntry.Entry;
					this.objAddressEntry.Visible = false;
				}
			}
			else if (m_objResource is AddressEntryNA)
            {
				if(this.objAddressEntryNA != null)
				{
					this.objAddressEntryNA.SaveSettings();
					m_objResource = this.objAddressEntryNA.Entry;
					this.objAddressEntryNA.Visible = false;
				}
			}
			else if (m_objResource is DateEntry)
            {
				if(this.objDateEntry != null)
				{
					this.objDateEntry.SaveSettings();
					m_objResource = this.objDateEntry.Entry;
					this.objDateEntry.Visible = false;
				}
			}
			else if (m_objResource is DateEntryNA)
            {
				if(this.objDateEntryNA != null)
				{
					this.objDateEntryNA.SaveSettings();
					m_objResource = this.objDateEntryNA.Entry;
					this.objDateEntryNA.Visible = false;
				}
			}
			else if (m_objResource is DateTimeEntry)
            {
				if(this.objDateTimeEntry != null)
				{
					this.objDateTimeEntry.SaveSettings();
					m_objResource = this.objDateTimeEntry.Entry;
					this.objDateTimeEntry.Visible = false;
				}
			}
			else if (m_objResource is DateTimeEntryNA)
            {
                if(this.objDateTimeEntryNA != null)
				{
					this.objDateTimeEntryNA.SaveSettings();
					m_objResource = this.objDateTimeEntryNA.Entry;
					this.objDateTimeEntryNA.Visible = false;
				}
			}
			else if (m_objResource is MultiSelectEntry)
            {
				if(this.objMultiSelectEntry != null)
				{
					this.objMultiSelectEntry.SaveSettings();
					m_objResource = this.objMultiSelectEntry.Entry;
					this.objMultiSelectEntry.Visible = false;
				}
			}
			else if (m_objResource is MultiSelectOtherEntry)
            {
				if(this.objMultiSelectOtherEntry != null)
				{
					this.objMultiSelectOtherEntry.SaveSettings();
					m_objResource = this.objMultiSelectOtherEntry.Entry;
					this.objMultiSelectOtherEntry.Visible = false;
				}
			}
			else if (m_objResource is NameEntry)
            {
                if(this.objNameEntry != null)
				{
					this.objNameEntry.SaveSettings();
					m_objResource = this.objNameEntry.Entry;
					this.objNameEntry.Visible = false;
				}
			}
			else if (m_objResource is NoteEntry)
            {
                if(this.objNoteEntry != null)
				{
					this.objNoteEntry.SaveSettings();
					m_objResource = this.objNoteEntry.Entry;
					this.objNoteEntry.Visible = false;
				}
			}
			else if (m_objResource is NumberEntry)
            {
				if(this.objNumberEntry != null)
				{
					this.objNumberEntry.SaveSettings();
					m_objResource = this.objNumberEntry.Entry;
					this.objNumberEntry.Visible = false;
				}
			}
			else if (m_objResource is NumberEntryNA)
            {
				if(this.objNumberEntryNA != null)
				{
					this.objNumberEntryNA.SaveSettings();
					m_objResource = this.objNumberEntryNA.Entry;
					this.objNumberEntryNA.Visible = false;
				}
			}
			else if (m_objResource is PasswordEntry)
            {
				if(this.objPasswordEntry != null)
				{
					this.objPasswordEntry.SaveSettings();
					m_objResource = this.objPasswordEntry.Entry;
					this.objPasswordEntry.Visible = false;
				}
			}
			else if (m_objResource is PhoneEntry)
            {
				if(this.objPhoneEntry != null)
				{
					this.objPhoneEntry.SaveSettings();
					m_objResource = this.objPhoneEntry.Entry;
					this.objPhoneEntry.Visible = false;
				}
			}
			else if (m_objResource is PhoneEntryNA)
            {
				if(this.objPhoneEntryNA != null)
				{
					this.objPhoneEntryNA.SaveSettings();
					m_objResource = this.objPhoneEntryNA.Entry;
					this.objPhoneEntryNA.Visible = false;
				}
			}
			else if (m_objResource is PostalCodeEntry)
            {
				if(this.objPostalCodeEntry != null)
				{
					this.objPostalCodeEntry.SaveSettings();
					m_objResource = this.objPostalCodeEntry.Entry;
					this.objPostalCodeEntry.Visible = false;
				}
			}
			else if (m_objResource is PostalCodeEntryNA)
            {
				if(this.objPostalCodeEntryNA != null)
				{
					this.objPostalCodeEntryNA.SaveSettings();
					m_objResource = this.objPostalCodeEntryNA.Entry;
					this.objPostalCodeEntryNA.Visible = false;
				}
			}
			else if (m_objResource is SignatureCaptureEntry)
            {
				if(this.objSignatureCapture != null)
				{
					this.objSignatureCapture.SaveSettings();
					m_objResource = this.objSignatureCapture.Entry;
					this.objSignatureCapture.Visible = false;
				}
			}
			else if (m_objResource is SingleSelectEntry)
            {
				if(this.objSingleSelectEntry != null)
				{
					this.objSingleSelectEntry.SaveSettings();
					m_objResource = this.objSingleSelectEntry.Entry;
					this.objSingleSelectEntry.Visible = false;
				}
			}
			else if (m_objResource is SingleSelectOtherEntry)
            {
				if(this.objSingleSelectOtherEntry != null)
				{
					this.objSingleSelectOtherEntry.SaveSettings();
					m_objResource = this.objSingleSelectOtherEntry.Entry;
					this.objSingleSelectOtherEntry.Visible = false;
				}
			}
			else if (m_objResource is TextEntry)
            {
				if(this.objTextEntry != null)
				{
					this.objTextEntry.SaveSettings();
					m_objResource = this.objTextEntry.Entry;
					this.objTextEntry.Visible = false;
				}
			}
			else if (m_objResource is YesNoEntry)
            {
				if(this.objYesNoEntry != null)
				{
					this.objYesNoEntry.SaveSettings();
					m_objResource = this.objYesNoEntry.Entry;
					this.objYesNoEntry.Visible = false;
				}
			}
			else if (m_objResource is GraphicDisplay)
            {
				if(this.objGraphicDisplay != null)
				{
					this.objGraphicDisplay.SaveSettings();
					m_objResource = this.objGraphicDisplay.Entry;
					this.objGraphicDisplay.Visible = false;
					this.txtPrompt.Visible = true;
				}
			}
            else if (m_objResource is GraphicAnnotation)
            {
                if (this.objGraphicAnnotation != null)
                {
                    this.objGraphicAnnotation.SaveSettings();
                    m_objResource = this.objGraphicAnnotation.Entry;
                    this.objGraphicAnnotation.Visible = false;
                    this.txtPrompt.Visible = true;
                }
            }
		}

		private void pnlSIP_EnabledChanged(object sender, System.EventArgs e)
		{
			if(pnlSIP.Enabled)
			{
				pnlEntry.Top = m_nNewLocation.Y;
			}
			else
			{
				pnlEntry.Top = m_nOriginalLocation.Y;
			}
		}

	}
}
